/** 索引 */

// 生成随机数 
function GetRandomNum(min, max) {
    let range = max - min;
    let rand = Math.random();

    return (min + Math.round(rand * range));
}
// 生成随机用户名
function GetRandomUserName(min, max) {
    let str = '123456789jklshgdfaqpowieurytmnxbcvz';
    let tempStringArray = str.split('');
    let outputtext = '';
    for (let i = 0; i < GetRandomNum(min, max); i++) {
        outputtext = outputtext + tempStringArray[GetRandomNum(0, tempStringArray.length)];
    }
    return outputtext;
}

var db = connect('company');
db.randomInfo.drop();

var startTime = (new Date()).getTime();
var tempInfo = [];
for (let i = 0; i < 2000000; i++) {
    tempInfo.push({
        userName: GetRandomUserName(6, 17),
        regediteTime: new Date(),
        random0: GetRandomNum(100000, 999999),
        random1: GetRandomNum(100000, 999999),
        random2: GetRandomNum(100000, 999999),
        random3: GetRandomNum(100000, 999999),
        random4: GetRandomNum(100000, 999999)
    });
}

db.randomInfo.insert(tempInfo);
var endTime = (new Date()).getTime() - startTime;
print('[endTime]:--------' + endTime + 'ms');
